package com.auzingers.docsorganizer.entity;

import java.util.List;

import android.test.AndroidTestCase;

import com.google.common.collect.ImmutableList;

public class TestGoogleResult extends AndroidTestCase {

    /**
     * Tests that the setEntries method sets the shared flag properly.
     */
    public void testSetEntries() {
        final GoogleResult result = new GoogleResult();
        result.setFeedAuthor(new GoogleAuthor("2", "2@2"));

        final GoogleDocument doc1 = new GoogleDocument();
        doc1.setAuthor(new GoogleAuthor("1", "1@1"));

        final GoogleDocument doc2 = new GoogleDocument();
        doc2.setAuthor(new GoogleAuthor("2", "2@2"));

        //check that shared flags haven't been set yet
        assertFalse(doc1.isSharedEntry());
        assertFalse(doc2.isSharedEntry());

        final List<GoogleEntry> entries = ImmutableList.<GoogleEntry>of(doc1, doc2);
        result.setEntries(entries);

        //check that flags have been set correctly
        assertTrue(doc1.isSharedEntry());
        assertFalse(doc2.isSharedEntry());
    }
}
